package com.ado.abyss.core.manager.impl;

import com.ado.abyss.core.dal.dao.SysMenuMapper;
import com.ado.abyss.core.dal.model.SysMenu;
import com.ado.abyss.core.manager.SysMenuManager;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author adonais
 * @date 2020/7/9
 * @description SysMenuManagerImpl
 **/
@Service(value = "sysMenuManager")
public class SysMenuManagerImpl extends ServiceImpl<SysMenuMapper , SysMenu> implements SysMenuManager {

    @Autowired
    private SysMenuMapper sysMenuMapper ;


    @Override
    public List<SysMenu> findByUserName(String name) {
        List<SysMenu> sysMenus = sysMenuMapper.findByUserName(name) ;
        return sysMenus;
    }

    @Override
    @Transactional
    public boolean deleteById(Long id) {
        boolean flag = false ;
        int result = sysMenuMapper.deleteByPrimaryKey(id) ;
        if(result == 1) {
            flag = true ;
        }
        return flag;
    }

    @Override
    @Transactional
    public boolean deleteByIds(List<Long> ids) {
        boolean flag = false ;
        int result = sysMenuMapper.deleteByIds(ids) ;
        if(result == 1) {
            flag = true ;
        }
        return flag;
    }

    @Override
    public List<SysMenu> findAll() {
        return sysMenuMapper.findAll();
    }
}
